<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xml:lang="en" lang="en">
	<h:head />
	<body>
		<ui:composition template="/rootWeb.xhtml">
	    <ui:define name="header">
	        <title>模具领用日志</title>
	        <script type="text/javascript">
				//页面载入时注册
	        	jQuery(document).ready(function(){
	        		//鼠标移入
					jQuery("#machineMoldTable_data tr").live("mouseover", function() {
					  	jQuery(this).css("background-color","ondine");
					});
					//鼠标移出
					jQuery("#machineMoldTable_data tr").live("mouseout", function() {
					  	jQuery(this).css("background-color","white");
					});
				});
				//模具查询条件设置
				function handleSetQueryMold(xhr, status, args) {
					if(args.selectedNull){
						alert(args.selectedNull);
						return ;
					}
					selectMoldDlg.hide();
				}
				//机台查询条件设置
				function handleSetQueryMachine(xhr, status, args) {
					if(args.selectedNull){
						alert(args.selectedNull);
						return ;
					}
					selectMachineDlg.hide();
				}
				
				function resetQueryCondition(){
					jQuery("#queryOccurDate_input").val('');
					jQuery("#queryMoldNumber").val('');
					jQuery("#queryMachineNumber").val('');
				}
			</script>
			<style type="text/css">
				
			</style>
		</ui:define>
	    <ui:define name="body">
	    	<h:form id="form" prependId="false">
	    	   <div style="white-space:nowrap;width:100%">
	    	   <h:panelGrid id="queryGrid" columns="12">
		    		<h:outputLabel for="queryOccurDate" value="领用日期："/>
		    		<p:calendar id="queryOccurDate" value="#{machineAction.queryMachineMold.occurDate}" size="15"
		    			timeZone="GMT+8" pattern="yyyy-MM-dd" showButtonPanel="true" navigator="true"/>
		    		<h:outputLabel for="queryMoldNumber" value="模具型号："/>
		    		<p:inputText id="queryMoldNumber" value="#{machineAction.queryMachineMold.mold.moldNumber}" />
		    		<p:commandButton  value="选择" action="#{machineAction.queryMold}"
		    		        oncomplete="selectMoldDlg.show();" update=":form:moldTable"/>
		    		<h:outputLabel for="queryMachineNumber" value="机台："/>
		    		<p:inputText id="queryMachineNumber" value="#{machineAction.queryMachineMold.machine.machineNumber}" />
		    		<p:commandButton  value="选择"  action="#{machineAction.queryMachine}"
		    		        oncomplete="selectMachineDlg.show();" update=":form:machineTable"/>
		    		<p:commandButton value="查询" action="#{machineAction.queryResultBycondition}" update=":form:machineMoldTable"  icon="ui-icon-search"/>
		    		<p:commandButton value="重置" onclick="resetQueryCondition();"/>
		    	</h:panelGrid> <p/>
		    	</div>
				<p:dataTable id="machineMoldTable" value="#{machineAction.moldTakingLogList}" var="log" rowKey="#{log}" emptyMessage="没有记录！"
	    				paginator="true" rows="10"  	rowsPerPageTemplate="5,10,15"	paginatorAlwaysVisible="false" 	paginatorPosition="bottom" currentPageReportTemplate="{currentPage} / {totalPages}"
               			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   >
               			<f:facet name="header">模具领用记录</f:facet>
               			<p:column headerText="模具型号">
               				<h:outputText  value="#{log.mold.moldNumber}"/>
               			</p:column>
               			<p:column headerText="模具系列">
               				<h:outputText  value="#{log.mold.moldSeries.seriesName}"/>
               			</p:column>
               			<p:column headerText="模具品名">
               				<h:selectOneMenu value="#{log.mold.moldName}" style="width: 120px" disabled="true">  
		    				 	<f:selectItem itemLabel="请选择"  itemValue=""/>
				                <f:selectItems value="#{machineAction.moldNameItems}"/>
				            </h:selectOneMenu>
               			</p:column>
               			<p:column headerText="机台">
               				<h:outputText  value="#{log.machine.machineNumber}"/>
               			</p:column>
               			<p:column headerText="领用时间">
               				<h:outputText  value="#{log.occurDate}">
               					<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" timeZone="GMT+8" />
               				</h:outputText>
               			</p:column>
               	</p:dataTable>
               	
               	<p:dialog id="selectMoldDlgID" header="选择模具" widgetVar="selectMoldDlg" modal="true" resizable="false" >
					<p:dataTable id="moldTable" value="#{machineAction.moldList}" var="mold" rowKey="#{mold}" emptyMessage="没有记录！" 
					    selection="#{machineAction.selectedMold}"
			    		paginator="true" rows="10"  	rowsPerPageTemplate="5,10,15"	paginatorAlwaysVisible="false" 	paginatorPosition="bottom" currentPageReportTemplate="{currentPage} / {totalPages}"
                 		paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   >
                 		<p:column selectionMode="single"/>
                 		<p:column headerText="模具型号">#{mold.moldNumber}</p:column>
                 		<p:column headerText="模具系列">#{mold.moldSeries.seriesName}</p:column>
                 		<p:column headerText="模具品名">
                            <h:selectOneMenu value="#{mold.moldName}" disabled="true" style="width:120px">  
				                <f:selectItems value="#{machineAction.moldNameItems}"/>
				            </h:selectOneMenu>
                        </p:column>
                 	</p:dataTable>
					<f:facet name="footer">
						<p:commandButton value="确定" action="#{machineAction.setQueryMold}" update=":form:queryMoldNumber" oncomplete="handleSetQueryMold(xhr, status, args)"/>
					</f:facet>
				</p:dialog>
				
               	<p:dialog id="selectMachineDlgID" header="选择机台" widgetVar="selectMachineDlg" modal="true" resizable="false" >
					<p:dataTable id="machineTable" value="#{machineAction.machineList}" var="machine" rowKey="#{machine}" emptyMessage="没有记录！" selection="#{machineAction.selectedMachine}"
			    		paginator="true" rows="10"  	rowsPerPageTemplate="5,10,15"	paginatorAlwaysVisible="false" 	paginatorPosition="bottom" currentPageReportTemplate="{currentPage} / {totalPages}"
                 		paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"   >
                 		<p:column selectionMode="single"/>
                 		<p:column headerText="机台编号">#{machine.machineNumber}</p:column>
               			<p:column headerText="描述">#{machine.machineRemark}</p:column>
               			<p:column headerText="机台状态">
               				<h:selectOneMenu value="#{machine.machineState}" disabled="true" style="width:120px">  
				                <f:selectItems value="#{machineAction.machineStateItems}"/>
				            </h:selectOneMenu>
               			</p:column>
                 	</p:dataTable>
					<f:facet name="footer">
						<p:commandButton value="确定" action="#{machineAction.setQueryMachine}" update=":form:queryMachineNumber" oncomplete="handleSetQueryMachine(xhr, status, args)"/>
					</f:facet>
				</p:dialog>
			</h:form>
	    </ui:define>
		</ui:composition>
	</body>
</html>
